{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#coding = utf-8\n",
    "import tushare as ts\n",
    "import pandas as pd\n",
    "\n",
    "import sys\n",
    "default_encoding = 'utf-8'\n",
    "if sys.getdefaultencoding() != default_encoding:\n",
    "    reload(sys)\n",
    "    sys.setdefaultencoding(default_encoding)\n",
    "\n",
    "ts.set_token('ec401353e11cd728472e9027e6d900387511e6c3cf5b54d8f277b18cc45f6bcd')\n",
    "fd = ts.Macro()\n",
    "df = fd.ChinaDataCPI(indicID='M030000003', field='indicName,periodDate,dataValue,dataSource')\n",
    "df = df.sort('periodDate', ascending=False)\n",
    "df.head()\n",
    "print type(df['indicName'][0])\n",
    "str=df['indicName'][0].decode(\"UTF-8\")\n",
    "print str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
